import http from '@/utils/request'

// 查询本周，查询上周都需要调两个接口，先调MainData得到主表信息，将主表的
// 点击图标的时候先判断本周以及上周的填报情况,再根据情况去请求接口，关于本周的就有两种情况，已填报则是查看接口，
// 未填报则是未填报接口


// 本周未填写时
// 获取主表信息
export const getNotFillThisWeekMainData = async(data) => {
  return http.get('/api/erp/hours/workmain/erpWorkingHours/queryWorkingHours', data)
}
// 通过主表信息获取任务信息
export const getNotFillThisWeekTaskData = async(data) => {
  return http.get('/api/erp/hours/workdetail/erpWorkingHoursDetailed/findThisWeekTask', data)
}



// 本周未撤回，提交本周填报
export const addNotFillThisWeekFormData = async(data) => {
  return http.post('/api/erp/hours/workmain/erpWorkingHours/add', data)
}
// 本周撤回过，提交本周填报
export const addRevokeThisWeekFormData = async(data) => {
  return http.put('/api/erp/hours/workmain/erpWorkingHours/edit', data)
}


// 撤回本周填报,改为删除数据
export const revokeThisWeekFormData = async(data) => {
  // return http.put('/api/erp/hours/workmain/erpWorkingHours/revoke', data)
  return http.delete('/api/erp/hours/workmain/erpWorkingHours/delete', data)
}




// 查看本周任务
export const getFilledThisWeekMainData = async(data) => {
  return http.get('/api/erp/hours/workmain/erpWorkingHours/queryHistoryWorkingHours', data)
}
export const getFilledThisWeekTaskData = async(data) => {
  return http.get('/api/erp/hours/workdetail/erpWorkingHoursDetailed/findHistoryWeekTask', data)
}
// 撤回后重填的提交
// 查看上周任务
// 提交上周补填

// 查看生产人员类型
export const getTaskInputUserType = async(data) => {
  return http.get('/api/erp/hours/personneltype/erpProductionPersonnelType/getUserTypeByUserId', data)
}
// 获取人员填报情况
export const getTaskInputDataStatus = async(data) => {
  return http.get('/api/erp/hours/workmain/erpWorkingHours/canFillIn', data)
}
// 查询历史工时
export const queryHisWorkingHours = async(data) => {
  return http.get('/api/erp/hours/workmain/erpWorkingHours/queryDayHistoryWorkingHours', data)
}
// 补填时全部提交
export const allSubmitUrl = async(data) => {
  return http.put('/api/erp/hours/workmain/erpWorkingHours/missAllSubmit', data)
}
// 获取单据编号
export const generatedFormNumber = async({
		url='/api/erp/hours/workmain/erpWorkingHours/getBillNo',
		prefix='GSTB', 
		subSystemCode='05', 
		type
	}) => {
	// 如我用的场景，需要prefix:GSTB,subSystemCode:05
	// type则是miss----上周的    fill_in----本周的
	const _url = url ? url : '/api/erp/base/generatedFormNumber'
	return http.get(_url, { prefix: prefix || 'GSTB', subSystemCode: subSystemCode || '05', type }).then((res) => {
		if (res.success) {
		  return res.result
		}
	})
}